﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Net.Mail;
using System.Net;
using System.IO;

namespace CapaNegocio
{
    public class negEnviarCorreo
    {
        #region singleton
        private static readonly negEnviarCorreo _instancia = new negEnviarCorreo();
        public static negEnviarCorreo Instancia
        {
            get { return negEnviarCorreo._instancia; }
        }
        #endregion

        #region "Metodos"
        public Boolean enviaCorreo(string correoDestinatario)
        {
            Boolean resultado = false;
            try
            {
                //Configurando el cliente SMTP
                SmtpClient client = new SmtpClient();
                client.Host = "smtp.gmail.com";
                client.Port = 587;
                client.EnableSsl = true;
                client.DeliveryMethod = SmtpDeliveryMethod.Network;
                client.UseDefaultCredentials = false;
                client.Credentials = new NetworkCredential("hotelpullman2014@gmail.com", "pullman2014");

                //Enviando correo
                MailMessage mail = new MailMessage();
                mail.From = new MailAddress("hotelpullman2014@gmail.com");
                mail.To.Add(new MailAddress(correoDestinatario));
                mail.Subject = "Confirmacion de Reserva - HOTEL PULLMAN.";
                mail.IsBodyHtml = true;
                mail.Body = "<div style='font-family: arial, Helvetica, sans-serif; padding: 10px'>" +
                     "   <div style='display: inline-block; float: left; position: static; width: 100%'>" +
                      "      <img alt='' src='http://www.reservas.net/prvimagen/2128_logo.jpg' style='position: static; display: inline(-block) '/>" +
    "&nbsp &nbsp <div style='position: static; margin-left: 15%; vertical-align: 120%; display: inline-block; color: #CC3300; text-decoration: underline;'>" +
                                "<h2>HOTEL PULLMAN </h2></div></div> <br/>" +
                        "<p>  Usted acaba de realizar con exito una reserva en nuestro sistema.</p>" +
                        "<div style='border-color: rgb(253, 166, 94); border-top-style: double;'><ul>" +
                         "   <h4>DATOS DE CONTACTO:</h4>" +
                          "  <ul><li> <h4> Teléfono: </h4> (044)22-3589 </li>" +
                           "     <li> <h4> Ubicanos en: </h4>Jr. Pizarro 879 – Centro Histórico - Trujillo - Perú</li>" +
                            "    <li> <h4> Email:  </h4>  contacto@pullmanhoteltrujillo.com.pe </li>";
               // mail.Attachments.Add(new Attachment("D:/prueba.pdf"));
                client.Send(mail);
                resultado = true;
            }
            catch (Exception e)
            {
                throw e;
            }
            return resultado;
        }
        #endregion
    }
}
